package com.itheima.hello.hello入门进阶.JavaBean封装.基础知识;

public class Student {
    public String name;
    private double chinese;
    private double English;
    private int age;
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getChinese() {
        return chinese;
    }

    public void setChinese(double chinese) {
        if (chinese<0 || chinese>100){
            System.out.println("成绩有误");
        }else {
        this.chinese = chinese;
    }}

    public double getEnglish() {
        return English;
    }

    public void setEnglish(double english) {
        if (english<0 || english>100){
            System.out.println("成绩有误");
        }
        else {
            this.English = english;
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

//在创建一个有参构造器后一定要补上一个无参构造器
    public Student() { //无参构造器:格式和创建一个方法类似但是构造器没有返回值类型，不用写void,也没有return!
    }

    public Student(String name, double chinese, double english, int age) { //有参构造器
        this.name = name;
        this.chinese = chinese;
        this.English = english;
        this.age = age;
    }
}
